﻿@using CandidateManager.ViewsParams
@using CandidateManager.Extensions
@using strconsts = WI.CandidateManager.Common.Data.Constants.StringConstants
@model WI.CandidateManager.Common.Data.Entities.EntityBase

@{
    var parameters = (GenericPostParams)ViewData[strconsts.Parameters];
}

@using (Html.BeginForm())
{
    @Html.ValidationSummary(true)

    <h2>@Model.GetType().Name</h2>
    
    <table class="bordered">
        @foreach (var propertyName in parameters.PropertiesToDisplay)
        {
            <tr>
                <td class="vertical-header">
                    @Html.Label(propertyName)
                </td>

                <td>
                    @(Model.GetType().GetProperty(propertyName).PropertyType.IsEnum
                      ? Html.DropDownList(propertyName, (Enum)Model.GetType().GetProperty(propertyName).GetValue(Model))
                      : Html.Editor(propertyName))
                    @Html.ValidationMessage(propertyName)
                </td>
            </tr>
        }

    </table>

    <p>
        @Html.ActionLink("Back", parameters.ListActionName, parameters.ControllerName, new { @class = "common-btn-large BlueColor" })
        <input class="common-btn-large BlueColor" type="submit" value="Submit" />
    </p>
}
